<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2019/6/6
 * Time: 14:13
 */

namespace app\mobile\controller;


use app\admin\model\CategoryList;
use app\admin\model\LeaveWord;
use app\admin\model\LunboList;

class Massage extends Base
{


    public function massage(){
        if ($this->request->isPost()){
            $post = input('post.');
            $validate = $this->validate($post,'app\index\validate\Massage');
            if (true !== $validate){
                return json(['code'=>0,'msg'=>$validate]);
            }
            $data = [
                'username'=>$post['username'],
                'telephone'=>$post['telephone'],
                'wechat'=>$post['wechat'],
                'email'=>$post['email'],
                'content'=>$post['content']
            ];
            $ret = LeaveWord::create($data);
            if (!$ret){
                return json(['code'=>0,'msg'=>'提交失败']);
            }
            return json(['code'=>1,'msg'=>'提交成功']);
        }
        $lunbo = LunboList::where('category_id',14)->order('sort desc')->select();
        $category = CategoryList::where('id',14)->find();
        $this->assign('lunbo',$lunbo);
        $this->assign('cate_id',$category);
        return $this->fetch();
    }
}